<template>
	<view>
		<view v-for="(item, index) in datalist" style="margin: 10rpx;">
			<cardViewText :imgindex="index" :images="item.images" :title="item.title" :isTop="item.isTop"
				:author="item.author" :comments="item.comments" :time="item.time" :mode="item.mode"
				:bgColor="item.mode === 3 ? '#fef6e6' : '#fff'" @click="onCustomViewClick(index)">
				<template v-slot:tips>
					<view class="slotcontent" v-if="item.showSearch">
						<text>搜索：</text>
						<view class="borderbox"><text>今日金价</text></view>
						<view class="borderbox"><text>精选好物</text></view>
					</view>
				</template>
			</cardViewText>
		</view>
	</view>
</template>

<script>
	import cardViewText from "../../components/cardViewText.vue";
	export default {
		components: {
			cardViewText
		},
		data() {
			return {
				datalist: [{
						nId: "T15627",
						title: "14个月从100家开到1000家门店，蜜雪为何买下这家精酿啤酒商",
						isTop: true,
						author: "界面新闻",
						comments: 56,
						time: "2025.10.07",
						showSearch: false,
						mode: 1,
						images: []
					},
					{
						nId: "B4485",
						title: "把握历史大势，共创美好未来（观沧海）",
						isTop: false,
						author: "人民日报",
						comments: 1025,
						time: "2025.10.25",
						showSearch: false,
						mode: 2,
						images: ["/static/city1.png"]
					},
					{
						nId: "B5956",
						title: "黄金还能走多远？卖方高呼“第三浪启动”，230多份研报看多",
						isTop: false,
						author: "新华社",
						comments: 452,
						time: "2025.10.28",
						showSearch: true,
						mode: 2,
						images: ["/static/city2.jpg"]
					},
					{
						nId: "AD001",
						title: "加微信交友群，喜欢就聊，找喜欢的人",
						isTop: false,
						author: "我主良缘文化",
						comments: 0,
						time: "2025.10.08 09:50",
						showSearch: false,
						mode: 3,
						images: ["/static/city1.png", "/static/city2.jpg", "/static/city3.jpg"],
						bgColor: "#fef6e6"
					},
					{
						nId: "B5954",
						title: "奋进“十五五” 续写新篇章｜“人享其行、物畅其流”加快实现 重塑区域经济格局",
						isTop: false,
						author: "央视网",
						comments: 152200,
						time: "2025.10.28",
						showSearch: false,
						mode: 2,
						images: ["/static/city3.jpg"]
					},
					{
						nId: "S45895",
						title: "整治网络直播打赏乱象 中央网信办开展为期2个月专项行动",
						isTop: false,
						author: "央视网",
						comments: 59874,
						time: "2025.10.27",
						showSearch: false,
						mode: 2,
						images: ["/static/city4.jpg"]
					}
				]
			};
		},
		methods: {
			onCustomViewClick(index) {
				console.log("点击了第", index, "项");
			}
		}
	};
</script>

<style>
	.slotcontent {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		padding: 24rpx 0;
		font-size: 28rpx;
		color: #666;
		gap: 20rpx;
		border-top: 1rpx solid #f0f0f0;
		margin-top: 10rpx;
	}

	.borderbox {
		border: 1px solid #d0e3ff;
		border-radius: 12rpx;
		padding: 10rpx 20rpx;
		background: linear-gradient(135deg, #f0f7ff, #e1eeff);
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
	}

	.borderbox text {
		font-size: 24rpx;
		color: #1890ff;
		font-weight: 500;
	}
</style>